// 页面form 与 接口data 数据结构互相转换
// 检验检测
import dictUtil2 from '@/common/js/dictUtil2.js';
import {separator, imageDomain} from '@/common/js/resource.js';
import tool from '@/common/js/tools.js';
export default {
	/**
	 * 将接口返回的res.data转换成页面的formData
	 * @param {Object} data 接口返回的data
	 * @return {Object} 页面formData
	 */
	newForm(data) {
		return {
			id: data.ID || data.FangZhiID,
			companyId: data.QiYeID,
			person_id: data.RenYuanID,
			person_name: data.XingMing, // 姓名
			person_role: data.ZhiWu, // 岗位
			xiujia_statusId: data.XiuJiaZhuangTaiID + '', // 休假状态：正常、休假
			xiujia_status: data.XiuJiaZhuangTai, // 休假状态：正常、休假
			chuqin_statusId: data.ChuQinZhuangTaiID + '', // 出勤状态：上班、休息
			chuqin_status: data.ChuQinZhuangTai, // 出勤状态：上班、休息
			chenjian_statusId: data.ChenJianQingKuangID + '', // 晨检情况：正常、异常
			chenjian_status: data.ChenJianQingKuang, // 晨检情况：正常、异常
			images1: tool.addImageDomain(data.LiuDangZhaoPianUrl), // 留档照片
		}
	},
	/**
	 * 将接口返回的res.data转换成页面的dataList
	 * @param {Array} list 接口返回的list
	 * @return {Object} 页面dataList
	 */
	newFormList(list) {
		/*
		[{
			"ID":6,
			"QiYeID":1,
			"RenYuanID":3,
			"XingMing":"李丽丽1",
			"ZhiWu":"厨师",
			"XiuJiaZhuangTaiID":38,
			"XiuJiaZhuangTai":"正常",
			"ChuQinZhuangTaiID":40,
			"ChuQinZhuangTai":"上班",
			"ChenJianQingKuangID":42,
			"ChenJianQingKuang":"正常",
			"JianChaDate":"2024-05-30",
			"LiuDangZhaoPianUrl":null,
			"RecordCount":2
		},{"ID":5,"QiYeID":1,"RenYuanID":2,"XingMing":"三丰改","ZhiWu":"食品安全员","XiuJiaZhuangTaiID":38,"XiuJiaZhuangTai":"正常","ChuQinZhuangTaiID":40,"ChuQinZhuangTai":"上班","ChenJianQingKuangID":42,"ChenJianQingKuang":"正常","JianChaDate":"2024-05-30","LiuDangZhaoPianUrl":null,"RecordCount":2}]
		*/
		let arr = list.map(data => {
			return {
				id: data.ID || data.FangZhiID,
				companyId: data.QiYeID,
				person_id: data.RenYuanID,
				person_name: data.XingMing, // 姓名
				person_role: data.ZhiWu, // 岗位
				xiujia_statusId: data.XiuJiaZhuangTaiID + '', // 休假状态：正常、休假
				xiujia_status: data.XiuJiaZhuangTai, // 休假状态：正常、休假
				chuqin_statusId: data.ChuQinZhuangTaiID + '', // 出勤状态：上班、休息
				chuqin_status: data.ChuQinZhuangTai, // 出勤状态：上班、休息
				chenjian_statusId: data.ChenJianQingKuangID + '', // 晨检情况：正常、异常
				chenjian_status: data.ChenJianQingKuang, // 晨检情况：正常、异常
				images1: tool.addImageDomain(data.LiuDangZhaoPianUrl), // 留档照片
			}
		})
		return arr;
	},
}